home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt3sp4.arc / SENDMODE.PAS < prev    next >
Pascal/Delphi Source File  |  1985-09-04  |  4KB  |  93 lines

  1. (*----------------------------------------------------------------------*)
  2. (*             Send_Modem_Command --- Send command to modem             *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Send_Modem_Command( Modem_Text : AnyStr );
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Send_Modem_Command                                   *)
  10. (*                                                                      *)
  11. (*     Purpose:    Sends command to modem                               *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*         Send_Modem_Command( Modem_Text : AnyStr );                   *)
  16. (*                                                                      *)
  17. (*           Modem_Text --- text of command to send to modem            *)
  18. (*                                                                      *)
  19. (*     Calls:                                                           *)
  20. (*                                                                      *)
  21. (*        Async_Send                                                    *)
  22. (*        Async_Receive                                                 *)
  23. (*                                                                      *)
  24. (*     Remarks:                                                         *)
  25. (*                                                                      *)
  26. (*          If the string to be sent has not "Wait For" markers, then   *)
  27. (*          it is sent in its entirety in one call here.  If there ARE  *)
  28. (*          "Wait For" characters, then the flag WaitString_Mode is set *)
  29. (*          TRUE, Script_When_Text is set to the character to be found, *)
  30. (*          and  Script_When_Reply_Text is set to the remainder of the  *)
  31. (*          function key string.  This allows the terminal emulation to *)
  32. (*          properly process any received characters while PibTerm is   *)
  33. (*          waiting for the selected string to appear.                  *)
  34. (*                                                                      *)
  35. (*----------------------------------------------------------------------*)
  36.  
  37.  
  38. VAR
  39.    I:       INTEGER;
  40.    L:       INTEGER;
  41.    Ch:      CHAR;
  42.    MO_Char: CHAR;
  43.    Done:    BOOLEAN;
  44.  
  45. BEGIN (* Send_Modem_Command *)
  46.  
  47.    L      := LENGTH( Modem_Text );
  48.    I      := 1;
  49.    Done   := FALSE;
  50.  
  51.    WHILE( I <= L ) AND ( NOT Done ) DO
  52.       BEGIN
  53.  
  54.          MO_Char := Modem_Text[I];
  55.  
  56.          IF MO_Char = FK_CR THEN
  57.             Async_Send( CHR( CR ) )
  58.  
  59.          ELSE IF MO_Char = FK_Delay THEN
  60.             DELAY( One_Second_Delay )
  61.  
  62.          ELSE IF MO_Char = FK_Wait_For THEN
  63.             BEGIN   (* Wait For *)
  64.  
  65.                I := I + 1;
  66.  
  67.                IF ( I <= L ) THEN
  68.                   BEGIN
  69.                      WaitString_Mode        := TRUE;
  70.                      Script_When_Text       := Modem_Text[I];
  71.                      I                      := I + 1;
  72.                      IF ( I <= L ) THEN
  73.                         Script_When_Reply_Text := COPY( Modem_Text, I, L - I + 1 )
  74.                      ELSE
  75.                         Script_When_Reply_Text := '';
  76.                      Done                   := TRUE;
  77.                   END;
  78.  
  79.             END   (* Wait For *)
  80.  
  81.          ELSE
  82.             BEGIN
  83.                Async_Send( Modem_Text[I] );
  84.                IF ( Modem_Command_Delay > 0 )
  85.                   THEN DELAY( Modem_Command_Delay );
  86.             END;
  87.  
  88.          I := I + 1;
  89.  
  90.       END;
  91.  
  92. END   (* Send_Modem_Command *);
  93.